<template>
  <div class="container">
    <div class="main">
      <div class="content">
        <comTopBar />
        <!-- <newCom /> -->
        <div style="height: 120px;"></div>
        <div class="content_item" v-for="i in commentData">
          <!-- 左边 -->
          <div class="leftSide">
            <el-avatar :size="50" :src="i.userimg" />
          </div>
          <!-- 右边 -->
          <div class="rightSide">
            <div class="item_info">
                <div class="p_top">
                  <div class="p_username">
                    <p>{{i.username}}</p>
                  </div>
                  <div class="p_postTime">
                    <p>{{i.comTime}}</p>
                  </div>
                </div>
                <div class="p_bottom">
                  <p style="color: #777777;font-size: 14px;">{{i.comContent}}</p>
                </div>
              </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref , onMounted } from 'vue'
// import { getComment } from '@/api/comment'
// 引入pinia中的useStore库
import { useStore } from '@/stores/userData'
// 引入storeToRefs，使普通数据变为响应式数据
import { storeToRefs } from "pinia";
// 接收useStore
const store = useStore()
// 解构并使数据具有响应式
const { commentData } = storeToRefs(store);
onMounted(()=>{
  // getCommentData()
})
// const postID = ref('')
// const getCommentData = () => {
//   getComment(postID.value).then((res) => {
//     comContent.value = res.data.records
//     console.log(comContent.value);
//   })
// }
// const comContent = ref()
</script>
<style lang="scss" scoped>
.container {
  height: 100vh;
  width: 100%;
  overflow: hidden;
  position: relative;
}
.main{
  height: 90vh;
  width: 100%;
  position: absolute;
  top: calc(50% - 45vh);
  transition: 0.5s;
  display: grid;
  grid-template-columns: 78% 22%;
}
.content{
  background-color: #fff;
  border-left: 1px solid #D9DFE2;
  border-bottom-right-radius: 15px;
  border-top-right-radius: 15px;
  overflow-y: scroll;
}
.content::-webkit-scrollbar{
  display: none;
}
.content_item{
  margin: 20px;
  padding-bottom: 10px;
  border-bottom: 0.1px solid #dadada;
  // height: 120px;
  display: grid;
  grid-template-columns: 50px auto;
  .rightSide{
    margin: 0 10px;
    .item_info{
      display: grid;
      grid-template-rows: auto 1fr;
    }
    .p_top{
      display: flex;
      .p_username{
        margin: 0 10px 0 0;
        font-weight: bold;
      }
      .p_postTime{
        color: #999999;
      }
    }
    .p_bottom{
      margin-top: 2px;
      height: auto;
      table-layout: fixed;
      word-wrap: break-all;
      word-break: normal;
      overflow: hidden;
    }
  }
}
</style>
